/**
 *
 */
package ApacheCommons.BeanUtils;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;

import jdk8.User;
import org.junit.jupiter.api.Test;

/**
 * @Title:
 * @author zhoujie
 * @date 2018年6月29日 上午11:51:36
 *
 */
public class BeanAndMap {
    @Test
    public void beanToMap() throws Exception {
        User u = new User(1, "SKY");
        Map<String, String> map = BeanUtils.describe(u);
        System.out.println(map);
    }

    @Test
    public void MapTobean() throws Exception {
        Map<String, String> map = new HashMap<>();
        map.put("id", "1");
        map.put("name", "sky");
        User u = new User();
        BeanUtils.populate(u, map);
        System.out.println(u);
    }
}
